package com.george.common.api.feign.fallBack.order;

import com.george.common.api.feign.order.OrderServiceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Create By George on /2023/4/10
 * description: 订单Feign服务降级实现
 *
 * @author George
 */
@Slf4j
@Component
public class OrderServiceFeignFallBack implements FallbackFactory<OrderServiceFeign> {

    /**
     * Returns an instance of the fallback appropriate for the given cause
     */
    @Override
    public OrderServiceFeign create(Throwable cause) {

        return new OrderServiceFeign() {
            @Override
            public String createOrder(String userId, String orderId) {
                log.error("OrderServiceFeign: createOrder fail reason was: {}", cause.getMessage());
                return "创建订单失败，订单服务接口降级返回";
            }
        };
    }
}
